﻿Option Compare Text

Imports Microsoft.VisualBasic
Imports System.Xml.Serialization
Imports System.IO
Imports ComponentFactory.Krypton.Toolkit

Namespace Classes

    Module mFonctions

        Public LignesGrille As New GJSortableBindingList(Of LigneGrille) 'SortableSearchable
        Public Pouvoirs As New AggregationFichiersPouvoir  ' PouvoirsXML
        Public gsVersion As String


        ''' <summary>
        ''' La clé est le nom du controle bouton, la value la valeur figée
        ''' </summary>
        Public SaisiesFigees As New Dictionary(Of String, String)


        'Déclaration des Constantes
        Public Const C_NOM As Integer = 1
        Public Const C_TEXTETYPE As Integer = 5
        Public Const C_ORIGINE As Integer = 6
        Public Const C_NOMORIGINE As Integer = 2
        Public Const C_NIVEAU As Integer = 4
        Public Const C_DESCRIPTION As Integer = 7
        Public Const C_TYPE As Integer = 3
        Public Const C_FREQUENCE As Integer = 8
        Public Const C_MOTSCLES As Integer = 9
        Public Const C_TYPEACTION As Integer = 10
        Public Const C_TYPEATTAQUE As Integer = 11
        Public Const C_PORTEE As Integer = 12
        Public Const C_TABTEXTE1 As Integer = 13
        Public Const C_TYPETEXTE1 As Integer = 14
        Public Const C_TEXTE1 As Integer = 15
        Public Const C_TABTEXTE2 As Integer = 16
        Public Const C_TYPETEXTE2 As Integer = 17
        Public Const C_TEXTE2 As Integer = 18
        Public Const C_TABTEXTE3 As Integer = 19
        Public Const C_TYPETEXTE3 As Integer = 20
        Public Const C_TEXTE3 As Integer = 21
        Public Const C_TABTEXTE4 As Integer = 22
        Public Const C_TYPETEXTE4 As Integer = 23
        Public Const C_TEXTE4 As Integer = 24
        Public Const C_TABTEXTE5 As Integer = 25
        Public Const C_TYPETEXTE5 As Integer = 26
        Public Const C_TEXTE5 As Integer = 27
        Public Const C_TABTEXTE6 As Integer = 28
        Public Const C_TYPETEXTE6 As Integer = 29
        Public Const C_TEXTE6 As Integer = 30
        Public Const C_TABTEXTE7 As Integer = 31
        Public Const C_TYPETEXTE7 As Integer = 32
        Public Const C_TEXTE7 As Integer = 33
        Public Const C_TABTEXTE8 As Integer = 34
        Public Const C_TYPETEXTE8 As Integer = 35
        Public Const C_TEXTE8 As Integer = 36
        Public Const C_TABTEXTE9 As Integer = 37
        Public Const C_TYPETEXTE9 As Integer = 38
        Public Const C_TEXTE9 As Integer = 39
        Public Const C_TABTEXTE10 As Integer = 40
        Public Const C_TYPETEXTE10 As Integer = 41
        Public Const C_TEXTE10 As Integer = 42
        'Ajout des cases pour le Thème 2
        Public Const C_CASE1 As Integer = 43
        Public Const C_CASE2 As Integer = 44
        Public Const C_CASE3 As Integer = 45
        Public Const C_CASE4 As Integer = 46
        Public Const C_CASE5 As Integer = 47

        Public Const C_LIVRE As Integer = 48
        Public Const C_PAGE As Integer = 49

        Public Const C_IDPOUVOIR As Integer = 50
        Public Const C_ERREUR As Integer = 51

        Public Const C_MAXCOL As Integer = 51

        Public Const C_DECAL As Integer = 4

        Public Function bMEFNomPouvoir(ByRef vsNomPouvoir As String) As Boolean
            On Error GoTo Err_bMEFNomPouvoir

            If InStr(1, vsNomPouvoir, "Conduit divin :") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, vsNomPouvoir.Length - InStr(1, vsNomPouvoir, ":") - 1)
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Maîtrise de focaliseur arcanique ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Autorité naturelle ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Style de combat ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Tactique du roublard ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            'DE - 03/07/2010 - Ajout de la MEF de nouvelles Classes
            If InStr(1, vsNomPouvoir, "Censure du vengeur ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Compagnon spirituel ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Force indomptable ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Vertus des bardes ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Puissance du gardien ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Pacte occulte ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Magie sauvage ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Magie draconique ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Aspect primal ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Alliance divine ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            'DE - 03/06/2011 - Ajout de la MEF des nouvelles classes
            If InStr(1, vsNomPouvoir, "Manifestation élémentaire ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If
            If InStr(1, vsNomPouvoir, "Egide du mage d'armes ") <> 0 Then
                vsNomPouvoir = Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - InStr(1, vsNomPouvoir, "["))
                vsNomPouvoir = UCase(Microsoft.VisualBasic.Left(vsNomPouvoir, 1)) & Microsoft.VisualBasic.Right(vsNomPouvoir, Len(vsNomPouvoir) - 1)
                vsNomPouvoir = Microsoft.VisualBasic.Left(vsNomPouvoir, Len(vsNomPouvoir) - 1)
            End If

            bMEFNomPouvoir = True

Exit_bMEFNomPouvoir:
            Exit Function

Err_bMEFNomPouvoir:
            bMEFNomPouvoir = False
            GoTo Exit_bMEFNomPouvoir

        End Function

        Public Sub EditTheme1(ByRef voPDF As cPDF, ByVal txtDecalage As String, ByVal gsPouvoirs As String(,), ByVal gsVersion As String, ByVal DosIntegrer As Boolean, ByVal progressBarEdition As ProgressBar)
            If Not System.Diagnostics.Debugger.IsAttached Then
                On Error GoTo Err_EditTheme1
            End If
            'Declaration des variables
            Dim bSortie As Boolean, i As Integer, n As Integer
            Dim posj As Integer
            Dim sTexteRestant As String
            Dim rang As Integer
            Dim k As Integer
            Dim j As Integer
            Dim posX As Double
            Dim posY As Double
            Dim sImage As String
            Dim posXCurrent As Double
            Dim posYCurrent As Double
            Const TAILLE_MAX As Double = 235
            'Pour les Dos
            Dim sImageDos(9) As String
            Dim dDecalage As Double

            k = 0
            rang = 0
            bSortie = False
            sTexteRestant = ""
            posX = 20
            posY = 20
            posXCurrent = 20
            posYCurrent = 20

            If txtDecalage <> "" Then
                dDecalage = CDbl(txtDecalage)
            End If

            For n = 1 To 9
                sImageDos(n) = ""
            Next n

            For i = 1 To UBound(gsPouvoirs, 2)
                'On initialise bSortie pour un nouveau pouvoir
                bSortie = False
                posj = 0
                sTexteRestant = ""
                rang = 0

                'On revient ici pour la deuxième carte d'un pouvoir
Deuxieme_carte:
                If bSortie = True Then
                    rang = rang + 1
                Else
                    rang = 0
                End If

                k = k + 1
                If k = 10 Then
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
                    voPDF.PDFTextColor = Color.Black
                    voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)
                    k = 1
                    voPDF.PDFEndPage()

                    'Si chkDosIntegrer insérer ici une page de dos
                    If DosIntegrer Then
                        'On choisi l'image de fond
                        voPDF.PDFNewPage()

                        For n = 1 To 9
                            Select Case n
                                Case 3 '1
                                    posX = 20 + dDecalage
                                    posY = 20
                                Case 2
                                    posX = 210 + dDecalage
                                    posY = 20
                                Case 1 '3
                                    posX = 400 + dDecalage
                                    posY = 20
                                Case 6 '4
                                    posX = 20 + dDecalage
                                    posY = 290
                                Case 5
                                    posX = 210 + dDecalage
                                    posY = 290
                                Case 4 '6
                                    posX = 400 + dDecalage
                                    posY = 290
                                Case 9 '7
                                    posX = 20 + dDecalage
                                    posY = 560
                                Case 8
                                    posX = 210 + dDecalage
                                    posY = 560
                                Case 7 '9
                                    posX = 400 + dDecalage
                                    posY = 560
                            End Select

                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme1\" & sImageDos(n) & ".jpg", posX, posY, 180, 260)
                            sImageDos(n) = ""
                        Next n

                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
                        voPDF.PDFTextColor = Color.Black
                        voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)
                        voPDF.PDFEndPage()
                    End If

                    voPDF.PDFNewPage()
                End If
                'On choisi l'image de fond
                Select Case gsPouvoirs(C_ORIGINE, i)
                    Case "Aptitude"
                        sImage = "traits"
                        sImageDos(k) = "dostrait"
                    Case "Trait Racial"
                        sImage = "traits"
                        sImageDos(k) = "dostrait"
                    Case Else
                        Select Case gsPouvoirs(C_TYPE, i)
                            Case "Utilitaire"
                                Select Case Mid(gsPouvoirs(C_FREQUENCE, i), 1, 9)
                                    Case "A volonté", "À volonté"
                                        sImage = "utilitaireavolonte"
                                        sImageDos(k) = "dosutilitaire"
                                    Case "Rencontre"
                                        sImage = "utilitairerencontre"
                                        sImageDos(k) = "dosutilitaire"
                                    Case "Quotidien"
                                        sImage = "utilitairequotidien"
                                        sImageDos(k) = "dosutilitaire"
                                    Case Else
                                        sImage = "utilitaire"
                                        sImageDos(k) = "dosutilitaire"
                                End Select
                            Case Else
                                Select Case Mid(gsPouvoirs(C_FREQUENCE, i), 1, 9)
                                    Case "A volonté", "À volonté"
                                        sImage = "avolonte"
                                        sImageDos(k) = "dosavolonte"
                                    Case "Rencontre"
                                        sImage = "rencontre"
                                        sImageDos(k) = "dosrencontre"
                                    Case "Quotidien"
                                        sImage = "quotidien"
                                        sImageDos(k) = "dosquotidien"
                                    Case Else
                                        sImage = "inconnue"
                                        sImageDos(k) = "dosinconnue"
                                End Select
                        End Select
                End Select

                Select Case k
                    Case 1
                        posX = 20
                        posY = 20
                    Case 2
                        posX = 210
                        posY = 20
                    Case 3
                        posX = 400
                        posY = 20
                    Case 4
                        posX = 20
                        posY = 290
                    Case 5
                        posX = 210
                        posY = 290
                    Case 6
                        posX = 400
                        posY = 290
                    Case 7
                        posX = 20
                        posY = 560
                    Case 8
                        posX = 210
                        posY = 560
                    Case 9
                        posX = 400
                        posY = 560
                End Select

                'Nom du pouvoir
                If bMEFNomPouvoir(gsPouvoirs(C_NOM, i)) = False Then
                    MsgBox("Problème lors de la mise en forme du pouvoir " & gsPouvoirs(C_NOM, i), MsgBoxStyle.OkOnly)
                End If

                If Len(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", "")) < 21 Then
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 12, cPDF.PDFFontStl.FONT_BOLD)
                ElseIf Len(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", "")) < 30 Then
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 10, cPDF.PDFFontStl.FONT_BOLD)
                Else
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 9, cPDF.PDFFontStl.FONT_BOLD)
                End If
                voPDF.PDFTextColor = Color.White
                voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_CENTER
                voPDF.PDFBorder = cPDF.PDFBorderValue.BORDER_NONE
                voPDF.PDFFill = False
                voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme1\" & sImage & ".jpg", posX, posY, 180, 260)
                voPDF.PDFCell(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", ""), posX, posY, 180, 15)

                'Texte Type
                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 9, cPDF.PDFFontStl.FONT_NORMAL)
                voPDF.PDFCell(gsPouvoirs(C_TEXTETYPE, i), posX, posY + 12, 180, 15)

                voPDF.PDFTextColor = Color.Black
                'Description
                If gsPouvoirs(C_DESCRIPTION, i) <> "" Then
                    If Len(gsPouvoirs(C_DESCRIPTION, i)) > 150 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_ITALIC)
                        voPDF.PDFCell(gsPouvoirs(C_DESCRIPTION, i), posX + 37, posY + 36, 103, 7, , , posYCurrent)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_ITALIC)
                        voPDF.PDFCell(gsPouvoirs(C_DESCRIPTION, i), posX + 27, posY + 36, 133, 8, , , posYCurrent)
                    End If
                Else
                    posYCurrent = posY + 12 + 40
                End If

                'Mots cles
                If gsPouvoirs(C_MOTSCLES, i) <> "" Then
                    If Len(gsPouvoirs(C_MOTSCLES, i)) < 45 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                    End If
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                    voPDF.PDFCell(gsPouvoirs(C_MOTSCLES, i), posX, If(posY + 62 < posYCurrent + 10, posYCurrent + 9, posY + 62), 133, 10, , , posYCurrent)
                Else
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                    posY = If(posY + 62 < posYCurrent + 10, posYCurrent + 9, posY + 62)
                End If

                'Type action
                If gsPouvoirs(C_TYPEACTION, i) <> "" Then
                    If Len(gsPouvoirs(C_TYPEACTION, i)) > 15 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                    End If
                    voPDF.PDFCell(gsPouvoirs(C_TYPEACTION, i), posX, posYCurrent + 10, 66, 10, , posXCurrent)
                End If

                'Type Attaque
                If gsPouvoirs(C_TYPEATTAQUE, i) <> "" Then
                    If gsPouvoirs(C_TYPEACTION, i) = "Interruption immédiate" Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_BOLD)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                    End If

                    voPDF.PDFCell(gsPouvoirs(C_TYPEATTAQUE, i), posXCurrent + 10, posYCurrent + 10, 66, 10, , posXCurrent, posYCurrent)
                End If

                'Portée
                If gsPouvoirs(C_PORTEE, i) <> "" Then
                    If Len(gsPouvoirs(C_PORTEE, i)) < 22 Then
                        If gsPouvoirs(C_TYPEACTION, i) = "Interruption immédiate" Then
                            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_BOLD)
                        Else
                            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                        End If

                        If gsPouvoirs(C_TYPEATTAQUE, i) = "Corps à corps" Then
                            voPDF.PDFCell(gsPouvoirs(C_PORTEE, i), posXCurrent + 8, posYCurrent, 60, 10, , posXCurrent, posYCurrent)
                        Else
                            voPDF.PDFCell(gsPouvoirs(C_PORTEE, i), posXCurrent + 5, posYCurrent, 60, 10, , posXCurrent, posYCurrent)
                        End If
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_BOLD)
                        voPDF.PDFCell(gsPouvoirs(C_PORTEE, i), posXCurrent + 5, posYCurrent, 70, 10, , posXCurrent, posYCurrent)
                    End If
                    'voPDF.PDFCell(gsPouvoirs(C_PORTEE, i), posXCurrent + 5, posYCurrent, 60, 10, , posXCurrent, posYCurrent)
                End If

                'TRAITER ICI LE CAS DE DEUXIEME CARTE
                If bSortie = True Then
                    If posj = C_TEXTE1 Then
                        bSortie = False
                        'Tab texte 1
                        'if gsPouvoirs(C_TABTEXTE1,i) = 1 then posX = posX + C_DECAL

                        'Type texte 1
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                        'DE - 03/07/2010 - Suppression de Texte Trait : et Texte 
                        If gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Trait : " And gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Aptitude : " Then
                            voPDF.PDFCell(gsPouvoirs(C_TYPETEXTE1, i), posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 12, 66, 10, , posXCurrent, posYCurrent)
                        Else
                            voPDF.PDFCell(" ", posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 10, 66, 10, , posXCurrent, posYCurrent)
                        End If

                        'Texte 1
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_NORMAL)
                        voPDF.PDFCell(sTexteRestant, posXCurrent + 4, posYCurrent, posX + 120 - posXCurrent, 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                        If bSortie = True Then
                            posj = C_TEXTE1
                        Else
                            posj = 0
                        End If
                    End If
                Else
                    'Tab texte 1
                    'if gsPouvoirs(C_TABTEXTE1,i) = 1 then posX = posX + C_DECAL

                    'Type texte 1
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                    'DE - 03/07/2010 - Suppression de Texte Trait : et Texte 
                    If gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Trait : " And gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Aptitude : " Then
                        'GJ : A verifier : avant <>"FAUX "etait = 1
                        voPDF.PDFCell(gsPouvoirs(C_TYPETEXTE1, i), posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 10, 66, 10, , posXCurrent, posYCurrent)
                    Else 'GJ : A verifier : avant <>"FAUX "etait = 1
                        voPDF.PDFCell(" ", posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "FAUX", C_DECAL, 0), posYCurrent + 10, 60, 10, , posXCurrent, posYCurrent)
                        Mid(gsPouvoirs(C_TEXTE1, i), 1, 1) = UCase(Mid(gsPouvoirs(C_TEXTE1, i), 1, 1))
                    End If

                    'Texte 1
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_NORMAL)
                    If gsPouvoirs(C_TEXTE1, i) <> "" Then 'GJ : A verifier : avant <>"FAUX "etait = 1
                        voPDF.PDFCell(gsPouvoirs(C_TEXTE1, i), posXCurrent + 4, posYCurrent, posX + 120 - posXCurrent, 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "FAUX", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                    End If
                    If bSortie = True Then
                        posj = C_TEXTE1
                    Else
                        posj = 0
                    End If
                End If
                'SI ON SORT ON REMONTE AVEC LE TEXTE RESTANT
                If bSortie = True Then
                    If posj <> C_TEXTE1 Then
                        j = posj
                        bSortie = False

                        If gsPouvoirs(j + 1, i) <> "" Then
                            'Tab texte x
                            'if gsPouvoirs(j,i) = 1 then posX = posX + C_DECAL

                            'Type Texte x
                            If Len(gsPouvoirs(j + 1, i)) > 11 Then
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                            Else
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                            End If
                            voPDF.PDFCell(gsPouvoirs(j + 1, i), posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), posYCurrent + 10, 100, 10, , posXCurrent, posYCurrent)

                            'Texte x
                            'TRAITER ICI LE CAS DE DEUXIEME CARTE
                            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_NORMAL)
                            voPDF.PDFCell(sTexteRestant, posXCurrent + 4, posYCurrent, posX + 120 - posXCurrent, 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                            'SI ON SORT ON REMONTE AVEC LE TEXTE RESTANT
                            '	et le rang j
                            If bSortie = True Then
                                posj = j
                            Else
                                posj = posj + 3
                            End If
                        End If
                    End If
                End If

                If bSortie = False Then
                    If posj = 0 Then
                        posj = C_TABTEXTE2
                    End If
                    For j = posj To C_TABTEXTE10 Step 3
                        If gsPouvoirs(j + 1, i) <> "" Then
                            'Tab texte x
                            'if gsPouvoirs(j,i) = 1 then posX = posX + C_DECAL

                            'Si le label depasse la taille max on sort tout de suite
                            If (posYCurrent + 10) >= (TAILLE_MAX + posY - 20) Then
                                bSortie = True
                                sTexteRestant = gsPouvoirs(j + 2, i)
                                posj = j
                                Exit For
                            End If
                            'Type Texte x
                            If Len(gsPouvoirs(j + 1, i)) > 11 Then
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                            Else
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_BOLD)
                            End If 'GJ : A verifier : avant <>"FAUX "etait = 1
                            voPDF.PDFCell(gsPouvoirs(j + 1, i), posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), posYCurrent + 10, 100, 10, , posXCurrent, posYCurrent)

                            'Texte x
                            'TRAITER ICI LE CAS DE DEUXIEME CARTE
                            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_NORMAL)
                            If gsPouvoirs(j + 2, i) <> "" Then 'GJ : A verifier : avant <>"FAUX "etait = 1
                                voPDF.PDFCell(gsPouvoirs(j + 2, i), posXCurrent + 4, posYCurrent, posX + 120 - posXCurrent, 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                            End If
                            'SI ON SORT ON REMONTE AVEC LE TEXTE RESTANT
                            '	et le rang j
                            If bSortie = True Then
                                posj = j
                                Exit For
                            End If
                        End If
                    Next j
                End If

                'Livre et page
                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_NORMAL)
                voPDF.PDFTextColor = Color.White
                Select Case k
                    Case 1
                        posX = 20
                        posY = 264
                    Case 2
                        posX = 210
                        posY = 264
                    Case 3
                        posX = 400
                        posY = 264
                    Case 4
                        posX = 20
                        posY = 290 + 244
                    Case 5
                        posX = 210
                        posY = 290 + 244
                    Case 6
                        posX = 400
                        posY = 290 + 244
                    Case 7
                        posX = 20
                        posY = 560 + 244
                    Case 8
                        posX = 210
                        posY = 560 + 244
                    Case 9
                        posX = 400
                        posY = 560 + 244
                End Select

                voPDF.PDFCell(gsPouvoirs(C_LIVRE, i), posX, posY, 33, 8)
                voPDF.PDFCell("Page " & gsPouvoirs(C_PAGE, i), posX + 150, posY + 6, 33, 10)
                If bSortie = True Then
                    GoTo Deuxieme_carte
                End If

                progressBarEdition.Value = i
                System.Windows.Forms.Application.DoEvents()

            Next i

            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
            voPDF.PDFTextColor = Color.Black
            voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)

            'Si chkDosIntegrer insérer les dos des cartes restants sur la dernière page
            If DosIntegrer Then
                'On choisi l'image de fond
                voPDF.PDFEndPage()
                voPDF.PDFNewPage()

                For n = 1 To k
                    Select Case n
                        Case 3 '1
                            posX = 20 + dDecalage
                            posY = 20
                        Case 2
                            posX = 210 + dDecalage
                            posY = 20
                        Case 1 '3
                            posX = 400 + dDecalage
                            posY = 20
                        Case 6 '4
                            posX = 20 + dDecalage
                            posY = 290
                        Case 5
                            posX = 210 + dDecalage
                            posY = 290
                        Case 4 '6
                            posX = 400 + dDecalage
                            posY = 290
                        Case 9 '7
                            posX = 20 + dDecalage
                            posY = 560
                        Case 8
                            posX = 210 + dDecalage
                            posY = 560
                        Case 7 '9
                            posX = 400 + dDecalage
                            posY = 560
                    End Select

                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme1\" & sImageDos(n) & ".jpg", posX, posY, 180, 260)
                    sImageDos(n) = ""
                Next n

                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
                voPDF.PDFTextColor = Color.Black
                voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)
            End If

Exit_EditTheme1:
            Exit Sub

Err_EditTheme1:
            MsgBox("Erreur dans EditTheme1 (" & gsVersion & ")" & System.Environment.NewLine & Err.Description)
            GoTo Exit_EditTheme1

        End Sub

        Public Sub EditTheme2(ByRef voPDF As cPDF, ByVal txtDecalage As String, ByVal gsPouvoirs As String(,), ByVal gsVersion As String, ByVal DosIntegrer As Boolean, ByVal progressBarEdition As ProgressBar)
            On Error GoTo Err_EditTheme2
            'Declaration des variable
            Dim bSortie As Boolean, n As Integer, i As Integer
            Dim posj As Integer
            Dim sTexteRestant As String
            Dim rang As Integer
            Dim k As Integer
            Dim j As Integer
            Dim posX As Double
            Dim posY As Double
            Dim sImage As String
            Dim posXCurrent As Double
            Dim posYCurrent As Double
            Const TAILLE_MAX As Double = 220
            Const TAILLE_FONT_7 As Integer = 7
            Const TAILLE_FONT_6 As Integer = 6
            Dim iTaille_Font As Integer = 7
            'Pour les Dos
            Dim sImageDos(9) As String
            Dim dDecalage As Double
            'Pout les types d'action
            Dim sTypeAction As String
            Dim sFrequence As String
            Dim sSource As String
            'Pour les mots clés
            Dim sMotsCles() As String
            Dim lNbrMotsCles As Long
            Dim posXMC As Double
            Dim posYMC As Double
            'Pour les types d'attaque
            Dim sTypeAttaque As String
            'Pour les cases
            Dim bCases As Boolean = False
            Dim dDecalCase As Double
            Dim lNbrCases As Long
            'Pour les Distances et Tailles
            Dim sDistance As String
            Dim sTaille As String

            k = 0
            rang = 0
            bSortie = False
            sTexteRestant = ""
            posX = 20
            posY = 20
            posXCurrent = 20
            posYCurrent = 20
            ReDim sMotsCles(0)
            lNbrMotsCles = 0

            'iTaille_Font = TAILLE_FONT_7
            iTaille_Font = TAILLE_FONT_6

            If txtDecalage <> "" Then
                dDecalage = CDbl(txtDecalage)
            End If

            For n = 1 To 9
                sImageDos(n) = ""
            Next n

            For i = 1 To UBound(gsPouvoirs, 2)
                'On initialise bSortie pour un nouveau pouvoir
                bSortie = False
                posj = 0
                sTexteRestant = ""
                rang = 0

                'On revient ici pour la deuxième carte d'un pouvoir
Deuxieme_carte:
                If bSortie = True Then
                    rang = rang + 1
                Else
                    rang = 0
                End If

                k = k + 1
                If k = 10 Then
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
                    voPDF.PDFTextColor = Color.Black
                    voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)
                    k = 1
                    voPDF.PDFEndPage()

                    'Si chkDosIntegrer insérer ici une page de dos
                    If DosIntegrer = System.Windows.Forms.CheckState.Checked Then
                        'On choisi l'image de fond
                        voPDF.PDFNewPage()

                        For n = 1 To 9
                            Select Case n
                                Case 3 '1
                                    posX = 20 + dDecalage
                                    posY = 20
                                Case 2
                                    posX = 210 + dDecalage
                                    posY = 20
                                Case 1 '3
                                    posX = 400 + dDecalage
                                    posY = 20
                                Case 6 '4
                                    posX = 20 + dDecalage
                                    posY = 290
                                Case 5
                                    posX = 210 + dDecalage
                                    posY = 290
                                Case 4 '6
                                    posX = 400 + dDecalage
                                    posY = 290
                                Case 9 '7
                                    posX = 20 + dDecalage
                                    posY = 560
                                Case 8
                                    posX = 210 + dDecalage
                                    posY = 560
                                Case 7 '9
                                    posX = 400 + dDecalage
                                    posY = 560
                            End Select

                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sImageDos(n) & ".jpg", posX, posY, 180, 260)
                            sImageDos(n) = ""
                        Next n

                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
                        voPDF.PDFTextColor = Color.Black
                        voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)
                        voPDF.PDFEndPage()
                    End If

                    voPDF.PDFNewPage()
                End If
                'On choisi l'image de fond
                Select Case gsPouvoirs(C_ORIGINE, i)
                    Case "Aptitude"
                        sImage = "aptitude"
                        sImageDos(k) = "dostrait"
                    Case "Trait Racial"
                        sImage = "trait"
                        sImageDos(k) = "dostrait"
                    Case Else
                        Select Case gsPouvoirs(C_TYPE, i)
                            Case "Utilitaire"
                                Select Case Mid(gsPouvoirs(C_FREQUENCE, i), 1, 9)
                                    Case "A volonté", "À volonté"
                                        sImage = "utilitaireavolonte"
                                        sImageDos(k) = "dosutilitaire"
                                    Case "Rencontre"
                                        sImage = "utilitairerencontre"
                                        sImageDos(k) = "dosutilitaire"
                                    Case "Quotidien"
                                        sImage = "utilitairequotidien"
                                        sImageDos(k) = "dosutilitaire"
                                    Case Else
                                        sImage = "utilitaire"
                                        sImageDos(k) = "dosutilitaire"
                                End Select
                            Case Else
                                Select Case Mid(gsPouvoirs(C_FREQUENCE, i), 1, 9)
                                    Case "A volonté", "À volonté"
                                        sImage = "avolonte"
                                        sImageDos(k) = "dosavolonte"
                                    Case "Rencontre"
                                        sImage = "rencontre"
                                        sImageDos(k) = "dosrencontre"
                                    Case "Quotidien"
                                        sImage = "quotidien"
                                        sImageDos(k) = "dosquotidien"
                                    Case Else
                                        sImage = "inconnue"
                                        sImageDos(k) = "dosinconnue"
                                End Select
                        End Select
                End Select

                Select Case k
                    Case 1
                        posX = 20
                        posY = 20
                    Case 2
                        posX = 210
                        posY = 20
                    Case 3
                        posX = 400
                        posY = 20
                    Case 4
                        posX = 20
                        posY = 290
                    Case 5
                        posX = 210
                        posY = 290
                    Case 6
                        posX = 400
                        posY = 290
                    Case 7
                        posX = 20
                        posY = 560
                    Case 8
                        posX = 210
                        posY = 560
                    Case 9
                        posX = 400
                        posY = 560
                End Select

                Select Case Mid(gsPouvoirs(C_FREQUENCE, i), 1, 9)
                    Case "A volonté", "À volonté"
                        sFrequence = "avolonte"
                    Case "Rencontre"
                        sFrequence = "rencontre"
                    Case "Quotidien"
                        sFrequence = "quotidien"
                    Case Else
                        sFrequence = "inconnue"
                End Select

                If gsPouvoirs(C_TYPE, i) = "Utilitaire" Then sFrequence = "utilitaire"
                'If gsPouvoirs(C_TYPE, i) = "Utilitaire" Then sFrequence = "utilitaire" & sFrequence

                If InStr(1, gsPouvoirs(C_MOTSCLES, i), "arcanique") <> 0 Then
                    sSource = "arcanique"
                ElseIf InStr(1, gsPouvoirs(C_MOTSCLES, i), "divine") <> 0 Then
                    sSource = "divine"
                ElseIf InStr(1, gsPouvoirs(C_MOTSCLES, i), "martiale") <> 0 Then
                    sSource = "martiale"
                ElseIf InStr(1, gsPouvoirs(C_MOTSCLES, i), "primale") <> 0 Then
                    sSource = "primale"
                ElseIf InStr(1, gsPouvoirs(C_MOTSCLES, i), "psionique") <> 0 Then
                    sSource = "psionique"
                ElseIf InStr(1, gsPouvoirs(C_MOTSCLES, i), "ombre") <> 0 Then
                    sSource = "ombre"
                Else
                    sSource = "aucune"
                End If

                Select Case gsPouvoirs(C_TYPEACTION, i)
                    Case "Aucune"
                        sTypeAction = sFrequence & "_" & "aucune" & "_" & sSource
                    Case "Action libre"
                        sTypeAction = sFrequence & "_" & "libre" & "_" & sSource
                    Case "Action mineure"
                        sTypeAction = sFrequence & "_" & "mineure" & "_" & sSource
                    Case "Action de mouvement"
                        sTypeAction = sFrequence & "_" & "mouvement" & "_" & sSource
                    Case "Action simple", "Action d'opportunité"
                        sTypeAction = sFrequence & "_" & "simple" & "_" & sSource
                    Case "Interruption immédiate"
                        sTypeAction = sFrequence & "_" & "interruption" & "_" & sSource
                    Case "Réaction immédiate"
                        sTypeAction = sFrequence & "_" & "reaction" & "_" & sSource
                    Case Else
                        sTypeAction = sFrequence & "_" & "inconnue" & "_" & sSource
                End Select

                If (sTypeAction = sFrequence & "_" & "inconnue" & "_" & sSource) And (InStr(gsPouvoirs(C_TYPEACTION, i), "Réaction") <> 0) Then
                    sTypeAction = sFrequence & "_" & "reaction" & "_" & sSource
                End If

                Select Case gsPouvoirs(C_TYPEATTAQUE, i)
                    Case "Corps à corps"
                        If gsPouvoirs(C_NOM, i) = "Attaque de base de corps à corps" Then
                            sTypeAttaque = sFrequence & "_basecac"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "ou Distance*" And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_cacdistance"
                        ElseIf Not (gsPouvoirs(C_PORTEE, i) Like "ou Distance*") And gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*" Then
                            'Reste à faire Animale
                            'sTypeAttaque = sFrequence & "_animalecac"
                            sTypeAttaque = sFrequence & "_cac"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "ou Distance*" And gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*" Then
                            'Reste à faire Animale
                            'sTypeAttaque = sFrequence & "_animalecacdistance"
                            sTypeAttaque = sFrequence & "_cacdistance"
                        ElseIf gsPouvoirs(C_PORTEE, i) = "contact" And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_contact"
                            'Reste à faire Esprit
                        ElseIf Not (gsPouvoirs(C_PORTEE, i) Like "ou Distance*") And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_cac"
                        Else
                            sTypeAttaque = sFrequence & "_inconnue"
                        End If
                    Case "Distance"
                        If gsPouvoirs(C_NOM, i) = "Attaque de base à distance" Then
                            sTypeAttaque = sFrequence & "_basedistance"
                        ElseIf gsPouvoirs(C_PORTEE, i) <> "mire" And gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*" Then
                            'Reste à faire Animale
                            'sTypeAttaque = sFrequence & "_animaledistance"
                            sTypeAttaque = sFrequence & "_distance"
                        ElseIf gsPouvoirs(C_PORTEE, i) = "mire" And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_mire"
                            'Reste à faire Esprit
                        ElseIf gsPouvoirs(C_PORTEE, i) <> "mire" And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_distance"
                        Else
                            sTypeAttaque = sFrequence & "_inconnue"
                        End If
                    Case "Personnelle"
                        sTypeAttaque = sFrequence & "_personnelle"
                    Case "Zone"
                        If gsPouvoirs(C_PORTEE, i) Like "explosion*" Then
                            sTypeAttaque = sFrequence & "_zoneexplosion"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "décharge*" Then
                            sTypeAttaque = sFrequence & "_zonedecharge"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "mur*" Then
                            sTypeAttaque = sFrequence & "_zonemur"
                        Else
                            sTypeAttaque = sFrequence & "_inconnue"
                        End If
                    Case "Proximité"
                        If gsPouvoirs(C_PORTEE, i) Like "explosion*" And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_proximiteexplosion"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "décharge*" And Not (gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*") Then
                            sTypeAttaque = sFrequence & "_proximitedecharge"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "mur*" Then
                            sTypeAttaque = sFrequence & "_proximitemur"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "explosion*" And gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*" Then
                            'Reste à faire Animale
                            'sTypeAttaque = sFrequence & "_animaleexplosion"
                            sTypeAttaque = sFrequence & "_zoneexplosion"
                        ElseIf gsPouvoirs(C_PORTEE, i) Like "décharge*" And gsPouvoirs(C_MOTSCLES, i) Like "*forme animale*" Then
                            'Reste à faire Animale
                            'sTypeAttaque = sFrequence & "_animaledecharge"
                            sTypeAttaque = sFrequence & "_zonedecharge"
                            'Reste à faire Esprit
                        Else
                            sTypeAttaque = sFrequence & "_inconnue"
                        End If
                    Case Else
                        sTypeAttaque = sFrequence & "_inconnue"
                End Select

                'Images pour l'entête
                voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sImage & ".jpg", posX, posY, 180, 260)
                'Type Action
                If gsPouvoirs(C_TYPEACTION, i) <> "" Then
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sTypeAction & ".jpg", posX, posY, 44, 44)
                End If
                'Type Attaque
                posXMC = 180 - 44
                If gsPouvoirs(C_TYPEATTAQUE, i) <> "" Then
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sTypeAttaque & ".jpg", posX + posXMC, posY, 44, 44)
                End If
                'Nom du pouvoir
                If bMEFNomPouvoir(gsPouvoirs(C_NOM, i)) = False Then
                    MsgBox("Problème lors de la mise en forme du pouvoir " & gsPouvoirs(C_NOM, i), MsgBoxStyle.OkOnly)
                End If

                voPDF.PDFTextColor = Color.White
                voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_CENTER
                voPDF.PDFBorder = cPDF.PDFBorderValue.BORDER_NONE
                voPDF.PDFFill = False
                Select Case Len(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", ""))
                    Case Is > 25
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_BOLD)
                        voPDF.PDFCell(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", ""), posX + 42, posY, 85, 9, , , posYCurrent)
                    Case Is > 20
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 10, cPDF.PDFFontStl.FONT_BOLD)
                        voPDF.PDFCell(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", ""), posX + 42, posY, 98, 10, , , posYCurrent)
                    Case Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 11, cPDF.PDFFontStl.FONT_BOLD)
                        voPDF.PDFCell(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", ""), posX + 42, posY, 98, 12, , , posYCurrent)
                End Select
                'voPDF.PDFCell(gsPouvoirs(C_NOM, i) & If(rang <> 0, " (" & rang & ")", ""), posX + 42, posY, 98, 12, , , posYCurrent)

                'Mots cles
                If gsPouvoirs(C_MOTSCLES, i) <> "" Then
                    'Ajout des logos pour les mots clés
                    ReDim sMotsCles(0)
                    lNbrMotsCles = 0
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "acide") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "acide"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "électricité") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "electricite"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "feu") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "feu"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "force") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "force"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "froid") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "froid"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "nécrotique") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "necrotique"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "poison") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "poison"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "psychique") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "psychique"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "radiant") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "radiant"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If
                    If InStr(1, gsPouvoirs(C_MOTSCLES, i), "tonnerre") <> 0 Then
                        ReDim Preserve sMotsCles(lNbrMotsCles)
                        sMotsCles(lNbrMotsCles) = "tonnerre"
                        lNbrMotsCles = lNbrMotsCles + 1
                    End If

                    posXMC = 180 - 38
                    posYMC = 44

                    Select Case lNbrMotsCles
                        Case 0 'Pas de mots clés détectés -> on ne fait rien

                        Case 1
                            'voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(0) & ".jpg", posX + posXMC, posY + posYMC, 36, 36)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(0) & ".jpg", posX + posXMC + 9, posY + posYMC + 9, 18, 18)
                        Case 2
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(0) & ".jpg", posX + posXMC + 18, posY + posYMC, 18, 18)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(1) & ".jpg", posX + posXMC, posY + posYMC + 18, 18, 18)
                        Case 3
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(0) & ".jpg", posX + posXMC, posY + posYMC, 18, 18)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(1) & ".jpg", posX + posXMC + 18, posY + posYMC, 18, 18)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(2) & ".jpg", posX + posXMC + 9, posY + posYMC + 18, 18, 18)
                        Case 4
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(0) & ".jpg", posX + posXMC, posY + posYMC, 18, 18)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(1) & ".jpg", posX + posXMC + 18, posY + posYMC, 18, 18)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(2) & ".jpg", posX + posXMC, posY + posYMC + 18, 18, 18)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(3) & ".jpg", posX + posXMC + 18, posY + posYMC + 18, 18, 18)
                        Case Else '5 mots clés ou plus
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(0) & ".jpg", posX + posXMC, posY + posYMC, 12, 12)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(1) & ".jpg", posX + posXMC + 24, posY + posYMC, 12, 12)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(2) & ".jpg", posX + posXMC + 12, posY + posYMC + 12, 12, 12)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(3) & ".jpg", posX + posXMC, posY + posYMC + 24, 12, 12)
                            voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\" & sMotsCles(4) & ".jpg", posX + posXMC + 24, posY + posYMC + 24, 12, 12)
                    End Select
                End If

                'Texte Type
                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 7, cPDF.PDFFontStl.FONT_NORMAL)
                voPDF.PDFCell(gsPouvoirs(C_TEXTETYPE, i), posX + 40, posY + 24, 180 - 40 - 40, 15)

                voPDF.PDFTextColor = Color.Black
                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_NORMAL)

                'Si le pouvoir posséde des cases
                If gsPouvoirs(C_CASE1, i) <> "" Then
                    bCases = True
                    dDecalCase = 35
                    lNbrCases = If(gsPouvoirs(C_CASE1, i) <> "", 1, 0) + If(gsPouvoirs(C_CASE2, i) <> "", 1, 0) + If(gsPouvoirs(C_CASE3, i) <> "", 1, 0) + If(gsPouvoirs(C_CASE4, i) <> "", 1, 0) + If(gsPouvoirs(C_CASE5, i) <> "", 1, 0)
                Else
                    dDecalCase = 0
                    bCases = False
                End If

                'On positionne les cases
                If gsPouvoirs(C_CASE1, i) <> "" Then
                    posXMC = 180 - 50
                    posYMC = 80 + (1 * 10)
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\carreblanc.jpg", posX + posXMC, posY + posYMC, 45, If(lNbrCases = 1 Or lNbrCases = 2 Or lNbrCases = 3, 40, If(lNbrCases = 4, 30, 24)))
                    voPDF.PDFCell(gsPouvoirs(C_CASE1, i), posX + posXMC, posY + posYMC - 10, 45, 10)
                End If
                If gsPouvoirs(C_CASE2, i) <> "" Then
                    posXMC = 180 - 50
                    posYMC = 80 + (2 * 10) + (1 * If(lNbrCases = 1 Or lNbrCases = 2 Or lNbrCases = 3, 40, If(lNbrCases = 4, 30, 24)))
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\carreblanc.jpg", posX + posXMC, posY + posYMC, 45, If(lNbrCases = 1 Or lNbrCases = 2 Or lNbrCases = 3, 40, If(lNbrCases = 4, 30, 24)))
                    voPDF.PDFCell(gsPouvoirs(C_CASE2, i), posX + posXMC, posY + posYMC - 10, 45, 10)
                End If
                If gsPouvoirs(C_CASE3, i) <> "" Then
                    posXMC = 180 - 50
                    posYMC = 80 + (3 * 10) + (2 * If(lNbrCases = 1 Or lNbrCases = 2 Or lNbrCases = 3, 40, If(lNbrCases = 4, 30, 24)))
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\carreblanc.jpg", posX + posXMC, posY + posYMC, 45, If(lNbrCases = 1 Or lNbrCases = 2 Or lNbrCases = 3, 40, If(lNbrCases = 4, 30, 24)))
                    voPDF.PDFCell(gsPouvoirs(C_CASE3, i), posX + posXMC, posY + posYMC - 10, 45, 10)
                End If
                If gsPouvoirs(C_CASE4, i) <> "" Then
                    posXMC = 180 - 50
                    posYMC = 80 + (4 * 10) + (3 * If(lNbrCases = 4, 30, 24))
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\carreblanc.jpg", posX + posXMC, posY + posYMC, 45, If(lNbrCases = 4, 30, 24))
                    voPDF.PDFCell(gsPouvoirs(C_CASE4, i), posX + posXMC, posY + posYMC - 10, 45, 10)
                End If
                If gsPouvoirs(C_CASE5, i) <> "" Then
                    posXMC = 180 - 50
                    posYMC = 80 + (5 * 10) + (4 * 24)
                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme2\carreblanc.jpg", posX + posXMC, posY + posYMC, 45, 24)
                    voPDF.PDFCell(gsPouvoirs(C_CASE5, i), posX + posXMC, posY + posYMC - 10, 45, 10)
                End If

                'Mots cles
                If gsPouvoirs(C_MOTSCLES, i) <> "" Then
                    If Len(gsPouvoirs(C_MOTSCLES, i)) > 40 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_6, cPDF.PDFFontStl.FONT_BOLD)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_BOLD)
                    End If
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                    If iTaille_Font = 7 Then
                        voPDF.PDFCell(gsPouvoirs(C_MOTSCLES, i), posX, posY + 44, 110, 10, , , posYCurrent)
                    Else
                        voPDF.PDFCell(gsPouvoirs(C_MOTSCLES, i), posX, posY + 44, 110, 10, , , posYCurrent)
                    End If
                Else
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                    posYCurrent = posY + 34
                End If

                'Type action
                If gsPouvoirs(C_TYPEACTION, i) <> "" Then
                    If Len(gsPouvoirs(C_TYPEACTION, i)) > 15 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_BOLD)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_BOLD)
                    End If
                    voPDF.PDFCell(gsPouvoirs(C_TYPEACTION, i), posX, posYCurrent + 12, 66, 10, , posXCurrent, posYCurrent)
                End If

                'Type Attaque
                If gsPouvoirs(C_TYPEATTAQUE, i) <> "" Then
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_BOLD)
                    voPDF.PDFCell(gsPouvoirs(C_TYPEATTAQUE, i), posX, posYCurrent + 12, 66, 10, , posXCurrent, posYCurrent)
                End If

                'Portée
                If gsPouvoirs(C_PORTEE, i) <> "" Then
                    If Len(gsPouvoirs(C_PORTEE, i)) > 9 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_BOLD)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, TAILLE_FONT_7, cPDF.PDFFontStl.FONT_BOLD)
                    End If
                    'voPDF.PDFCell(gsPouvoirs(C_PORTEE, i), posXCurrent + 10, posYCurrent, 100, 10, , posXCurrent, posYCurrent)
                    voPDF.PDFCell(gsPouvoirs(C_PORTEE, i), posXCurrent + 6, posYCurrent, 100, 10, , posXCurrent, posYCurrent)
                    'Ajout des chiffres de distance et de taille
                    sDistance = ""
                    sTaille = ""
                    Select Case gsPouvoirs(C_TYPEATTAQUE, i)
                        Case "Distance"
                            If IsNumeric(gsPouvoirs(C_PORTEE, i)) Then
                                sDistance = CInt(gsPouvoirs(C_PORTEE, i))
                            End If

                        Case "Zone"
                            'explosion 1 à 10 cases ou moins
                            sTaille = Microsoft.VisualBasic.Left(gsPouvoirs(C_PORTEE, i), InStr(1, gsPouvoirs(C_PORTEE, i), "à") - 1)
                            sTaille = CInt(Microsoft.VisualBasic.Right(sTaille, 3))
                            sDistance = Microsoft.VisualBasic.Right(gsPouvoirs(C_PORTEE, i), Len(gsPouvoirs(C_PORTEE, i)) - InStr(1, gsPouvoirs(C_PORTEE, i), "à"))
                            sDistance = CInt(Microsoft.VisualBasic.Left(sDistance, 3))

                        Case "Proximité"
                            'décharge 1
                            'explosion 1 (3 au niveau 11, 5 au niveau 21)
                            If InStr(1, gsPouvoirs(C_PORTEE, i), "(") <> 0 Then
                                sTaille = Microsoft.VisualBasic.Left(gsPouvoirs(C_PORTEE, i), InStr(1, gsPouvoirs(C_PORTEE, i), "(") - 1)
                                sTaille = CInt(Microsoft.VisualBasic.Right(sTaille, 3))
                            Else
                                sTaille = CInt(Microsoft.VisualBasic.Right(gsPouvoirs(C_PORTEE, i), 2))
                            End If

                    End Select
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_CENTER
                    If sDistance <> "" Then
                        voPDF.PDFCell(sDistance, posX + 136, posY + 32, 20, 10)
                    End If
                    If sTaille <> "" Then
                        voPDF.PDFCell(sTaille, posX + 165, posY + 32, 20, 10)
                    End If
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                End If

                'TRAITER ICI LE CAS DE DEUXIEME CARTE
                If bSortie = True Then
                    If posj = C_TEXTE1 Then
                        bSortie = False
                        'Tab texte 1
                        'if gsPouvoirs(C_TABTEXTE1,i) = 1 then posX = posX + C_DECAL

                        'Type texte 1
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_BOLD)
                        'DE - 03/07/2010 - Suppression de Texte Trait : et Texte 
                        If gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Trait : " And gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Aptitude : " Then
                            If iTaille_Font = TAILLE_FONT_7 Then
                                voPDF.PDFCell(gsPouvoirs(C_TYPETEXTE1, i), posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 12, 100, 10, , posXCurrent, posYCurrent)
                            ElseIf iTaille_Font = TAILLE_FONT_6 Then
                                voPDF.PDFCell(gsPouvoirs(C_TYPETEXTE1, i), posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 9, 90, 10, , posXCurrent, posYCurrent)
                            End If

                        Else
                            voPDF.PDFCell(" ", posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 12, 100, 10, , posXCurrent, posYCurrent)
                        End If

                        'Texte 1
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_NORMAL)
                        If iTaille_Font = TAILLE_FONT_7 Then
                            voPDF.PDFCell(sTexteRestant, posXCurrent + 4, posYCurrent, posX + 130 - posXCurrent + If(bCases = True, -dDecalCase, 0), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                        ElseIf iTaille_Font = TAILLE_FONT_6 Then
                            voPDF.PDFCell(sTexteRestant, posXCurrent + 4, posYCurrent, posX + 120 - posXCurrent + If(bCases = True, -dDecalCase, 0), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                        End If
                        If bSortie = True Then
                            posj = C_TEXTE1
                        Else
                            posj = 0
                        End If
                    End If
                Else
                    'Tab texte 1
                    'if gsPouvoirs(C_TABTEXTE1,i) = 1 then posX = posX + C_DECAL

                    'Type texte 1
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_BOLD)
                    'DE - 03/07/2010 - Suppression de Texte Trait : et Texte 
                    If gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Trait : " And gsPouvoirs(C_TYPETEXTE1, i) <> "Texte Aptitude : " Then
                        If iTaille_Font = TAILLE_FONT_7 Then
                            voPDF.PDFCell(gsPouvoirs(C_TYPETEXTE1, i), posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 12, 100, 10, , posXCurrent, posYCurrent)
                        ElseIf iTaille_Font = TAILLE_FONT_6 Then
                            voPDF.PDFCell(gsPouvoirs(C_TYPETEXTE1, i), posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 10, 90, 10, , posXCurrent, posYCurrent)
                        End If
                    Else
                        If iTaille_Font = TAILLE_FONT_7 Then
                            voPDF.PDFCell(" ", posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 12, 100, 10, , posXCurrent, posYCurrent)
                        ElseIf iTaille_Font = TAILLE_FONT_6 Then
                            voPDF.PDFCell(" ", posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), posYCurrent + 9, 90, 10, , posXCurrent, posYCurrent)
                        End If
                        Mid(gsPouvoirs(C_TEXTE1, i), 1, 1) = UCase(Mid(gsPouvoirs(C_TEXTE1, i), 1, 1))
                    End If

                    'Texte 1
                    voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_NORMAL)
                    If gsPouvoirs(C_TEXTE1, i) <> "" Then
                        If iTaille_Font = TAILLE_FONT_7 Then
                            voPDF.PDFCell(gsPouvoirs(C_TEXTE1, i), posXCurrent + 4, posYCurrent, posX + 130 - posXCurrent + If(bCases = True, -dDecalCase, 0), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                        ElseIf iTaille_Font = TAILLE_FONT_6 Then
                            voPDF.PDFCell(gsPouvoirs(C_TEXTE1, i), posXCurrent + 4, posYCurrent, posX + 115 - posXCurrent + If(bCases = True, -dDecalCase, -10), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(C_TABTEXTE1, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                        End If
                    End If
                    If bSortie = True Then
                        posj = C_TEXTE1
                    Else
                        posj = 0
                    End If
                End If
                'SI ON SORT ON REMONTE AVEC LE TEXTE RESTANT
                If bSortie = True Then
                    If posj <> C_TEXTE1 Then
                        j = posj
                        bSortie = False

                        If gsPouvoirs(j + 1, i) <> "" Then
                            'Tab texte x
                            'if gsPouvoirs(j,i) = 1 then posX = posX + C_DECAL

                            'Type Texte x
                            If Len(gsPouvoirs(j + 1, i)) > 11 Then
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_BOLD)
                            Else
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_BOLD)
                            End If
                            If iTaille_Font = TAILLE_FONT_7 Then
                                voPDF.PDFCell(gsPouvoirs(j + 1, i), posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), posYCurrent + 12, 100, 10, , posXCurrent, posYCurrent)
                            ElseIf iTaille_Font = TAILLE_FONT_6 Then
                                voPDF.PDFCell(gsPouvoirs(j + 1, i), posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), posYCurrent + 9, 100, 10, , posXCurrent, posYCurrent)
                            End If

                            'Texte x
                            'TRAITER ICI LE CAS DE DEUXIEME CARTE
                            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_NORMAL)
                            If iTaille_Font = TAILLE_FONT_7 Then
                                voPDF.PDFCell(sTexteRestant, posXCurrent + 4, posYCurrent, posX + 130 - posXCurrent + If(bCases = True, -dDecalCase, 0), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                            ElseIf iTaille_Font = TAILLE_FONT_6 Then
                                voPDF.PDFCell(sTexteRestant, posXCurrent + 4, posYCurrent, posX + 110 - posXCurrent + If(bCases = True, -dDecalCase, -10), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                            End If
                            'SI ON SORT ON REMONTE AVEC LE TEXTE RESTANT
                            '	et le rang j
                            If bSortie = True Then
                                posj = j
                            Else
                                posj = posj + 3
                            End If
                        End If
                    End If
                End If

                If bSortie = False Then
                    If posj = 0 Then posj = C_TABTEXTE2

                    For j = posj To C_TABTEXTE10 Step 3
                        If gsPouvoirs(j + 1, i) <> "" Then
                            'Tab texte x
                            'if gsPouvoirs(j,i) = 1 then posX = posX + C_DECAL

                            'Type Texte x
                            If Len(gsPouvoirs(j + 1, i)) > 11 Then
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_BOLD)
                            Else
                                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_BOLD)
                            End If
                            If iTaille_Font = TAILLE_FONT_7 Then
                                voPDF.PDFCell(gsPouvoirs(j + 1, i), posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), posYCurrent + 12, 100, 10, , posXCurrent, posYCurrent)
                            ElseIf iTaille_Font = TAILLE_FONT_6 Then
                                voPDF.PDFCell(gsPouvoirs(j + 1, i), posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), posYCurrent + 9, 100, 10, , posXCurrent, posYCurrent)
                            End If

                            'Texte x
                            'TRAITER ICI LE CAS DE DEUXIEME CARTE
                            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, iTaille_Font, cPDF.PDFFontStl.FONT_NORMAL)
                            If gsPouvoirs(j + 2, i) <> "" Then
                                If iTaille_Font = TAILLE_FONT_7 Then
                                    voPDF.PDFCell(gsPouvoirs(j + 2, i), posXCurrent + 4, posYCurrent, posX + 130 - posXCurrent + If(bCases = True, -dDecalCase, 0), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                                ElseIf iTaille_Font = TAILLE_FONT_6 Then
                                    voPDF.PDFCell(gsPouvoirs(j + 2, i), posXCurrent + 4, posYCurrent, posX + 110 - posXCurrent + If(bCases = True, -dDecalCase, -10), 9, , posXCurrent, posYCurrent, True, posX + If(gsPouvoirs(j, i) <> "0", C_DECAL, 0), (((k - 1) \ 3) * 270) + TAILLE_MAX, bSortie, sTexteRestant)
                                End If
                            End If
                            'SI ON SORT ON REMONTE AVEC LE TEXTE RESTANT
                            '	et le rang j
                            If bSortie = True Then
                                posj = j
                                Exit For
                            End If
                        End If
                    Next j
                End If

                'Description, Livre et page
                Select Case k
                    Case 1
                        posX = 20
                        posY = 270
                    Case 2
                        posX = 210
                        posY = 270
                    Case 3
                        posX = 400
                        posY = 270
                    Case 4
                        posX = 20
                        posY = 290 + 250
                    Case 5
                        posX = 210
                        posY = 290 + 250
                    Case 6
                        posX = 400
                        posY = 290 + 250
                    Case 7
                        posX = 20
                        posY = 560 + 250
                    Case 8
                        posX = 210
                        posY = 560 + 250
                    Case 9
                        posX = 400
                        posY = 560 + 250
                End Select
                If gsPouvoirs(C_DESCRIPTION, i) <> "" Then
                    voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                    voPDF.PDFTextColor = Color.Brown
                    If Len(gsPouvoirs(C_DESCRIPTION, i)) > 150 Then
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_ITALIC)
                        voPDF.PDFCell(gsPouvoirs(C_DESCRIPTION, i), posX, posY - 30, If(bCases = True, 80, 100), 7, , , posYCurrent)
                    Else
                        voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_ITALIC)
                        voPDF.PDFCell(gsPouvoirs(C_DESCRIPTION, i), posX, posY - 30, If(bCases = True, 80, 100), 7, , , posYCurrent)
                    End If
                End If

                voPDF.PDFAlignement = cPDF.PDFAlignValue.ALIGN_LEFT
                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 6, cPDF.PDFFontStl.FONT_NORMAL)
                voPDF.PDFTextColor = Color.White
                voPDF.PDFCell(gsPouvoirs(C_LIVRE, i), posX, posY, 140, 8)
                voPDF.PDFCell("Page " & gsPouvoirs(C_PAGE, i), posX + 150, posY, 33, 10)
                If bSortie = True Then
                    GoTo Deuxieme_carte
                End If

                progressBarEdition.Value = i
                System.Windows.Forms.Application.DoEvents()

            Next i

            voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
            voPDF.PDFTextColor = Color.Black
            voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)

            'Si chkDosIntegrer insérer les dos des cartes restants sur la dernière page
            If DosIntegrer = System.Windows.Forms.CheckState.Checked Then
                'On choisi l'image de fond
                voPDF.PDFEndPage()
                voPDF.PDFNewPage()

                For n = 1 To k
                    Select Case n
                        Case 3 '1
                            posX = 20 + dDecalage
                            posY = 20
                        Case 2
                            posX = 210 + dDecalage
                            posY = 20
                        Case 1 '3
                            posX = 400 + dDecalage
                            posY = 20
                        Case 6 '4
                            posX = 20 + dDecalage
                            posY = 290
                        Case 5
                            posX = 210 + dDecalage
                            posY = 290
                        Case 4 '6
                            posX = 400 + dDecalage
                            posY = 290
                        Case 9 '7
                            posX = 20 + dDecalage
                            posY = 560
                        Case 8
                            posX = 210 + dDecalage
                            posY = 560
                        Case 7 '9
                            posX = 400 + dDecalage
                            posY = 560
                    End Select

                    voPDF.PDFImage(My.Application.Info.DirectoryPath & "\images\theme1\" & sImageDos(n) & ".jpg", posX, posY, 180, 260)
                    sImageDos(n) = ""
                Next n

                voPDF.PDFSetFont(cPDF.PDFFontNme.FONT_ARIAL, 8, cPDF.PDFFontStl.FONT_ITALIC)
                voPDF.PDFTextColor = Color.Black
                voPDF.PDFTextOut("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")", voPDF.PDFPageWidth / 2 - voPDF.PDFGetStringWidth("Page " & voPDF.PDFPageNumber & " (" & gsVersion & ")"), voPDF.PDFPageHeight - voPDF.PDFTextHeight)
            End If

Exit_EditTheme2:
            Exit Sub

Err_EditTheme2:
            MessageErreur(Nothing, "Erreur dans EditTheme2 (" & gsVersion & ")" & System.Environment.NewLine & Err.Description)
            GoTo Exit_EditTheme2

        End Sub

        Public Function fbTestValCritere(ByVal veValCritere As eCritere, ByVal pouvoirEnCours As LigneGrille) As Boolean
            On Error GoTo Err_fbTestValCritere


            If pouvoirEnCours.NomOrigine <> If(veValCritere.Classe = "", pouvoirEnCours.NomOrigine, veValCritere.Classe) Then
                Return False
            End If
            If pouvoirEnCours.TypePouvoir <> If(veValCritere.TypePouvoir = "", pouvoirEnCours.TypePouvoir, veValCritere.TypePouvoir) Then
                Return False
            End If
            If CShort(pouvoirEnCours.Niveau) < If(veValCritere.NivDe = -1, CShort(pouvoirEnCours.Niveau), CShort(veValCritere.NivDe)) Then
                Return False
            End If
            If CShort(pouvoirEnCours.Niveau) > If(veValCritere.NivA = -1, CShort(pouvoirEnCours.Niveau), CShort(veValCritere.NivA)) Then
                Return False
            End If
            If pouvoirEnCours.NomOrigine <> If(veValCritere.Race = "", pouvoirEnCours.NomOrigine, veValCritere.Race) Then
                Return False
            End If
            If pouvoirEnCours.NomOrigine <> If(veValCritere.PouvoirTalent = False, pouvoirEnCours.NomOrigine, "Talent") Then
                Return False
            End If
            If pouvoirEnCours.TexteType = If(veValCritere.AptitudeClasse = False, pouvoirEnCours.TexteType, _
                                             If((InStr(pouvoirEnCours.TexteType, "Aptitude") <> 0) And (pouvoirEnCours.Origine = "Classe"), pouvoirEnCours.TexteType, "FAUX")) Then
            Else
                Return False
            End If
            If (veValCritere.Aptitudes) Then
                If Not ((InStr(pouvoirEnCours.TexteType, "Aptitude") <> 0) And (pouvoirEnCours.Origine = "Aptitude")) Then
                    Return False
                End If
            End If
            If pouvoirEnCours.TexteType = If(veValCritere.TraitsRaciaux = False, pouvoirEnCours.TexteType, _
                                             If((InStr(pouvoirEnCours.TexteType, "Trait") <> 0) And (pouvoirEnCours.Origine = "Trait Racial"), pouvoirEnCours.TexteType, "FAUX")) Then
            Else
                Return False
            End If

    
            Return True
Err_fbTestValCritere:
            MessageErreur(Nothing, "Erreur dans fbTestValCritere (" & gsVersion & ")" & System.Environment.NewLine & Err.Description)
            Return False

        End Function

        ''' <summary>
        ''' Determines whether the specified expression is numeric. http://support.microsoft.com/kb/329488
        ''' </summary>
        ''' <param name="Expression">The expression.</param>
        ''' <returns>
        ''' <c>true</c> if the specified expression is numeric; otherwise, <c>false</c>.
        ''' </returns>
        Public Function IsNumeric(ByVal Expression As Object) As Boolean
            Dim isNum As Boolean
            Dim retNum As Double
            isNum = [Double].TryParse(Convert.ToString(Expression), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, retNum)
            Return isNum
        End Function

        Public Sub MessageErreur(ByVal ex As Exception, ByVal titre As String)
            Dim texte As String
            texte = "Erreur " + titre
            While Not (ex Is Nothing)
                texte = texte + Environment.NewLine + ex.Message
                ex = ex.InnerException
            End While
            KryptonMessageBox.Show(texte, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        End Sub
    End Module

End Namespace